{extend name="template/base_default"}
{block name="header"}
<link rel="stylesheet" href="__CSS__/common.css">
<link rel="stylesheet" href="__CSS__/weui.min.css">
<link rel="stylesheet" href="__CSS__/index.css">
<link rel="stylesheet" href="__CSS__/weuix.min.css"/>
<script src="__JS__/zepto.min.js"></script>
<script src="__JS__/lrz.min.js"></script>

<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="__JS__/lodash.js"></script>
<link rel="stylesheet" href="__CSS__/editShop/style.css?v201711271436">
<style>
    .form-head{
        color: white;
        font-size: 16px;
        background-color: rgba(95, 110, 170, 0.4);
        border-radius: 5px;
        overflow: hidden;
        color:white;
        height:420px;
    }
    body{
        background-image:url("__IMG__/bj.png");
        background-size:cover;
        text-align: center;
        background-attachment:fixed;
    }
    .body-input{
        color: #dddddd;
        position: relative;
        outline: none;
        border: solid 1px #ffffff;
        background-color: rgba(255, 255, 255, 0);
        float: left;
        margin: auto;
        font-size: 16px;
        height: 41px;
        line-height: 41px;
        border-radius: 5px;
        width: 60%;
        font-family: "Microsoft YaHei UI";
    }
    .bottom-btn{
        width:50%;
        height:100%;
        float: left;
    }
    button{
        border: none;
        color:white;
    }
    .botton1{
        background-color: #FF0000;

    }
    .botton2{
        background-color: #131a34;
        width:50%;
    }
    .input-window{
        margin-left: auto;
        margin-right: auto;
        background-color: white;
        width:90%;
        height:150px;
        background-color: rgba(95, 110, 170, 0.4);
        border-radius: 10px;
        margin-top: 30px;
        margin-left: 20px;
        text-align: center;
        clear:both;
        position: relative;
        background-size:cover;
    }
    .aa{
        height:3px;
        background-color: white;
        width:40px;
        position:absolute;
        top: 30px;
        left:55px;
    }
    .bb{

        opacity: 0;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
        z-index:99;
        width:300px;
        position:absolute;
        top:0;
        left:0;
        height:140px;
    }
    li{
        list-style:none;
    }
    .store-box{

        height:90px;
        margin-top: 30px;
        width: 90%;
        color:#545454;
    }
    .form-input3-label{
        width:28%;
    }
    .store-box img {
        width:100px;
        height:100px;
        float:right;
        margin-right: 10px;
        margin-top: 10px;
    }
    .store-success{
        font-size: 18px;
        color:#545454;

        font-family: "Microsoft YaHei UI";
    }
    .store-text{
        float: left;
        margin-top: 30px;
        margin-left: 16px;
        text-align: left;

    }
    .store-detail{
        font-size: 14px;
        color:#8c8c8c;
        font-family: "Microsoft YaHei UI";
        margin-top: 12px;
    }
    .store-p{
        text-align: center;
        color:white;
        margin-top: 30px;
        font-family: "Microsoft YaHei UI";
        font-size: 18px;

    }
    .store-other {
        margin-top: 20px;
        margin-left: auto;
        margin-right: auto;
        height:80px;
        background-color: rgba(95, 110, 170, 0.4);
        border-radius: 10px;
        width:26%;
        margin-left: 20px;
        margin-top: 20px;
        color：white;
        float: left;
        line-height: 80px;
        text-align: center;
        color: white;


    }
    .store-other input{
        margin-right: 5px;
    }
    .store-other2 {
        margin-top: 20px;
        margin-left: auto;
        margin-right: auto;
        height:80px;
        background-color: white;
        border-radius: 10px;
        width:40%;
        margin-left: 20px;
        margin-top: 20px;

        float: left;
        line-height: 80px;
        text-align: center;
    }
    .form-head2{
        color: white;
        font-size: 16px;
        background-color: rgba(95, 110, 170, 0.4);
        border-radius: 5px;
        overflow: hidden;
        height:360px;
        float: left;
        width:100%;
        margin-top: 20px;
    }
    .store-other-img{
        width:50px;
        float: left;
        height:50px;
        margin-top: 14px;
        margin-left: 14px;
        border-radius: 10px;
    }
    .form-head2 input{
        width:10%;
        height:20px;
        line-height: 30px;


    }
    .bank{
        width:100%;
        height:50px;
        line-height: 30px;
        text-align: left;
        font-size: 16px;
        margin-left: 30px;
    }
    .form-input3-input{
        width:60%;

        height:32px;
        margin-top: 10px;
        line-height: 24px;
        padding: 5px;
    }
    .form-input3{
        height:42px;
    }
</style>
{/block}
{block name="body"}

<form action="{:url('login/register')}" method="post" style="width:95%;margin: auto">
    <div class="form-head" style="height:auto;margin-top:10px;">
        <input class="form-input3-input" id="seller_id" name="seller_id" type="hidden" value="{$seller_id}" >
        <div class="form-input3" >
            <label for="name" class="form-input3-label">商家名称:</label>
            <input class="form-input3-input" id="name" name="name" type="text" value="{$shop_info['name']}" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label for="name" class="form-input3-label">经营内容:</label>
            <input class="form-input3-input" id="scope" name="scope" type="text" value="{$shop_info['scope']}" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label for="name" class="form-input3-label">折扣率:</label>
            <input class="form-input3-input" id="discount_rate" name="discount_rate" type="text" value="{$shop_info['discount_rate']}" placeholder=" ">
        </div>

            <input class="form-input3-input" id="rack_back_rate" name="rack_back_rate" type="hidden" value="{$shop_info['rack_back_rate']}" placeholder=" ">

        <div class="form-input3" >
            <label for="name" class="form-input3-label">联系电话:</label>
            <input class="form-input3-input" id="contact_number" name="contact_number" type="text" value="{$shop_info['contact_number']}" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label for="name" class="form-input3-label">人均消费:</label>
            <input class="form-input3-input" id="price" name="price" type="text" value="{$shop_info['price']/100}" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label for="name" class="form-input3-label">商家地址:</label>
            <input class="form-input3-input" id="position" name="position" type="text" value="{$shop_info['position']}" placeholder=" ">
        </div>
        <div class="form-input3">
            <label for="name" class="form-input3-label">商家分类:</label>
            <div style="width: 60%;height: 32px; display: inline-block; text-align: left; color: #dddddd;position: relative;">
                <span id="selectCategoryName" style="width: 75%; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">{$cate_name}</span>
                <a id="selectCategory" style="position: absolute; right: 10px;" href="javascript:void(0);">编辑</a>
            </div>
            <input class="form-input3-input" id="category_id" name="category_id" type="hidden" value="{$shop_info['category_id']}" placeholder=" ">
        </div>




    </div>
    <div class="form-body" style="text-align: center">
        <div class="input-window" style="background-size:cover;background-image:url('__BASE__/index.php/picture/index?id={$shop_info['logo']}');width:80%;margin-left:auto;margin-right:auto;">
            {eq name="platform_type" value="2"}
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="logo"  value="{$shop_info['logo']}" />
            {/eq}
        </div>
        {for start="0" end="4" name="i" }
        {if condition="empty($main_img[$i])"}
        <div class="input-window" style="background-size:cover;background-image:url('__BASE__/index.php/picture/index?id=0');width:80%;margin-left:auto;margin-right:auto;">
            {eq name="platform_type" value="2"}
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="main_img{$i}"  value="" />
            {/eq}
        </div>
        {else /}
        <div class="input-window" style="background-size:cover;background-image:url('__BASE__/index.php/picture/index?id={$main_img[$i]}');width:80%;margin-left:auto;margin-right:auto;">
            {eq name="platform_type" value="2"}
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="main_img{$i}"  value="{$main_img[$i]}" />
            {/eq}
        </div>
        {/if}
        {/for}

        <div class="input-window" style="background-size:cover;background-image:url('__BASE__/index.php/picture/index?id={$shop_info['main_img_small']}');width:80%;margin-left:auto;margin-right:auto;">
            {eq name="platform_type" value="2"}
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="main_img_small"  value="{$shop_info['main_img_small']}" />
            {/eq}
        </div>
    </div>
    {eq name="platform_type" value="2"}
    <div style="position:fixed;bottom:0;left:0;width:100%;height:50px;z-index: 120;">
        <button id="delete" class="bottom-btn botton1" type="button">删除</button>
        <button id="submit" class="bottom-btn botton2" type="button">提交</button>
    </div>
    {/eq}

</form>
<div style="width:100%;height:70px;float: left">

</div>
<div id="shopCategory" style="display: none"></div>

{/block}
{block name="footer"}
<script type="text/javascript" src="__JS__/public.js"></script>
<script>
    $(function(){

        $('.headimgurl').change(function () {
            var v_this = $(this);
            lrz(this.files[0],{width:640,fieldName:"image"}).then(function (rst) {
                var formdata = new FormData();
                v_this.parent().css("background-image","url("+rst.base64+")");//无论是否上传成功都显示
                url = "__BASE__/web.php/file/upload_picture_base64";
                formdata.append("image", rst.base64);
                $.ajax({
                    url : url,
                    type : 'post',
                    data : formdata,
                    contentType : false,
                    processData : false,
                    dataType : "json",
                    success : function(data) {
                        if (data.status == true) {
                            $.toast("图片上传成功");
                            v_this.next().val(data.info[0]['id']);
                        }
                    },
                    error:function(){
                        $.toast("图片上传失败");
                    }
                });
                return false;
            })
        });
    })


    $('#submit').click(function () {
        var imgs = new Array();
        if($('#main_img0').val()!=0){
            imgs.push($('#main_img0').val());
        }
        if($('#main_img1').val()!=0){
            imgs.push($('#main_img1').val());
        }
        if($('#main_img2').val()!=0){
            imgs.push($('#main_img2').val());
        }
        if($('#main_img3').val()!=0){
            imgs.push($('#main_img3').val());
        }

        imgs_json = JSON.stringify(imgs);
        var body  ={
            seller_id:$('#seller_id').val(),
            name:$('#name').val(),
            scope:$('#scope').val(),
            discount_rate:$('#discount_rate').val(),
            contact_number:$('#contact_number').val(),
            position:$('#position').val(),
            price:$('#price').val(),
            logo:$('#logo').val(),
            main_img:imgs_json,
            main_img_small:$('#main_img_small').val(),
            category_id: $('#category_id').val()
        };
        var $this = $(this);
        $this.addClass('weui-btn_disabled').attr('disabled','disabled');
        ajax_post(getBaseUrl()+'web.php/extension/edit_shop',jQuery.param(body),{
            success:function(data){
                $.toast("修改成功",'success');
                $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                    setTimeout(
                            function(){
                                window.location.reload();
                            }
                            ,1500);
            },
            error:function(data){
                $.toptip(data.msg, 'error');
                $this.removeClass('weui-btn_disabled').removeAttr("disabled");
            }
        })


    });


    $('#delete').click(function () {

        var body  ={
            seller_id:$('#seller_id').val(),
            del:'del',
            platform_father:"{$platform_father}"
        };
        var $this = $(this);
        $this.addClass('weui-btn_disabled').attr('disabled','disabled');
        ajax_post(getBaseUrl()+'web.php/extension/edit_shop',jQuery.param(body),{
            success:function(data){
                $.toast("已发起删除请求",'success');
                $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                setTimeout(
                    function(){
                        history.back(-1);
                    }
                    ,1500);
            },
            error:function(data){
                $.toptip(data.data, 'error');
                $this.removeClass('weui-btn_disabled').removeAttr("disabled");
            }
        })



    });
</script>
<script>
    $('#selectCategory').click(function () {
        $('body').addClass('scroll-hidden');
        $('html').addClass('scroll-hidden');
//        $('#shopCategory').css("top", document.documentElement.scrollTop);
        $('#shopCategory').show();
    });
    window.baseImgSrc = "__BASE__/static/web/img";
    const cateItems = {$category};
</script>
<script src="__JS__/editShop/common.js?v201711271436"></script>
{/block}